[XENAPI] Added hard shutdown (aka. vm-destroy)
authorAlastair Tse <atse@xensource.com>
Fri, 6 Oct 2006 10:57:16 +0000 (11:57 +0100)
committerAlastair Tse <atse@xensource.com>
Fri, 6 Oct 2006 10:57:16 +0000 (11:57 +0100)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/scripts/xapi.py

index 411600044ec4b4938c09ebd7d9fd57e7ffb175df..41f10aca19dd34279311198aef6b0264fd33fdda 100644 (file)
@@ -37,6 +37,7 @@ COMMANDS = {
     'vbd-create': ('<domname> <pycfg>', 'Create VBD attached to domname'),
     'vif-create': ('<domname> <pycfg>', 'Create VIF attached to domname'),
     'vm-delete': ('<domname>', 'Delete VM'),
+    'vm-destroy': ('<name>', 'Hard shutdown a VM with name'),
 }
 
 class OptionError(Exception):
@@ -141,6 +142,16 @@ def xapi_vm_shutdown(*args):
     success = execute(server.VM.clean_shutdown, session, vm_uuid)
     print 'Done.'
 
+def xapi_vm_destroy(*args):
+    if len(args) < 1:
+        raise OptionError("No Domain name specified.")
+
+    server, session = _connect()
+    vm_uuid = execute(server.VM.get_by_label, session, args[0])
+    print 'Shutting down VM with force %s (%s)' % (args[0], vm_uuid)
+    success = execute(server.VM.hard_shutdown, session, vm_uuid)
+    print 'Done.'    
+
 def xapi_vbd_create(*args):
     if len(args) < 2:
         raise OptionError("Configuration file not specified")